﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Configuration;

namespace RADB
{
    [Serializable]
    public class OrderItemDTO
    {        
        public int tableID;
        public int productID;
        public int quantity;
    }
    public interface IDataTransfer
    {
        
        //Waiters
        DataTable getWaitingTables();
        DataTable getCategories();
        DataTable getProducts();
        bool placeAnOrder(int WaiterID, OrderItemDTO info);
        DataTable getReadyItems();
        bool deliverAnItem(int WaiterID, int itemID);
        bool setTableOccupied(int tableID);
        bool setTableDirty(int tableID);
        DataTable getOrderedItems(int tableId);
        DataTable getOrderStatusList();
        bool cancelAnOrder(int itemID);

        //Host
        DataTable getTables();
        bool setTableWaiting(int tableID);
        bool reserveTable(int tableID, DateTime startTime, DateTime finishTime);

        //Busboy
        DataTable getDirtyTables();
        bool setTableCleaning(int BusBoyID, int tableID);
        bool setTableAvailable(int tableID);
        
        //cook
        DataTable getWaitingItems();
        DataTable getCookingItems();
        bool setItemCooking(int CookID, int itemID);
        bool notifyAnItem(int itemID);
        
        int login(string username, string password);
        bool changePassword(int empId, string oldPassWord, string newPassWord);

        bool isManager(int id);
        bool isHost(int id);        
        bool isWaiter(int id);        
        bool isCook(int id);
        bool isBusBoy(int id);
    }
    public class IDataTransferFactory
    {
        static private HttpChannel channel;
        public static void RegisterChannel()
        {
            channel = new HttpChannel();
            ChannelServices.RegisterChannel(channel, false);
            //RemotingConfiguration.RegisterActivatedClientType(typeof(RADB.IDataTransfer),"http://localhost:26690");
        }
        public static IDataTransfer getDataTransferObject(string Address)
        {            

            //string Address = ConfigurationManager.AppSettings["RemoteObjAddress"];            
            //object RemoteObj = Activator.GetObject(typeof(IDataTransfer), Properties.Settings.Default.RemoteObjAddress);

            object RemoteObj = Activator.GetObject(typeof(IDataTransfer), Address);
          
            return (IDataTransfer)RemoteObj;            
        }
    }
}